package cn.signUpSystem.action;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.signUpSystem.pojo.Applicant;
import cn.signUpSystem.pojo.Position;

@Controller
@Scope("prototype")
public class ApplicantAction extends BaseAction<Applicant> {

	// 接受传送过来的职位id
	private Integer positionId;

	public Integer getPositionId() {
		return positionId;
	}

	public void setPositionId(Integer positionId) {
		this.positionId = positionId;
	}

	/**
	 * 记录招聘者信息
	 * 
	 * @return
	 */
	public String addApplicant() {
		Position position = positionService.queryOne(positionId);
		model.setPosition(position);
		applicantService.add(model);
		return "toIndex";
	}

	/**
	 * 查看所有应聘者信息
	 * 
	 * @return
	 */
	public String showAll() {
		List<Applicant> applicants = applicantService.queryAll();
		if (applicants.size() != 0) {
			request.put("applicants", applicants);
		}
		return "toAdminIndex";
	}

	/**
	 * 详细查看应聘者的信息
	 * 
	 * @return
	 */
	public String detail() {
		Integer id = (Integer) request.get("id");
		Applicant applicant = applicantService.queryOne(id);
		request.put("applicant", applicant);
		return "todetailUI";
	}
	
	/**
	 * 按职位分类查信息
	 * 
	 * @return
	 */
	public String showByPositionId() {
		Integer id = (Integer) request.get("id");
		List<Applicant> applicants = applicantService.queryByPositionId(id);
		request.put("applicants", applicants);
		return "toAdminIndex";
	}

}
